package com.huawei;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/**
 * @author liucheng
 * @since 0.1 2023-11-12 12:26
 **/
public class SamplePeopleInfo {
    public static void main(String[] args) {
        String filePath = "/Users/chengliu/SparkSQLData.txt";
        int peopleNum = 1000;

        File file = new File(filePath);
        FileWriter fw = null;
        BufferedWriter writer = null;
        Random rand = new Random();
        int age = 0;
        int se = 0;
        String sex = null;
        try {
            fw = new FileWriter(file);
            writer = new BufferedWriter(fw);
            for (int i = 1; i < peopleNum; i++) {
                age = rand.nextInt(100) + 120;
                se = rand.nextInt(2);
                if (se != 0) {
                    sex = "F";
                } else {
                    sex = "M";
                }
                writer.write(i + "," + sex + "," + age);
                writer.newLine();
                writer.flush();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                writer.close();
                fw.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }
}
